home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2.sit
/
Raven 1.2
/
Source
/
Foundation
/
Common
/
ZStackCrawl.h
< prev
next >
Wrap
Text File
|
1997-07-27
|
2KB
|
95 lines
/*
* File: ZStackCrawl.h
* Summary: Stack crawl class based on the class in the OpenDoc utilities.
* Written by: Jesse Jones
*
* Copyright ゥ 1997 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <2> 7/28/97 JDJ Added pragma once.
* <1> 2/02/97 JDJ Created.
*/
#pragma once
#include <stddef.h>
#include <ZTypes.h>
//-----------------------------------
// Forward References
//
class StackID;
//-----------------------------------
// Types
//
typedef const StackID* StackFrameID; // magic cookie
// ===================================================================================
// struct SStackFrame
// ===================================================================================
struct SStackFrame {
string name; // name of the function
const void* start; // pointer to the start of the function
size_t offset; // offset from the start of the function to the PC
bool native; // true if function is PPC code
};
// ===================================================================================
// class TStackCrawl
// ===================================================================================
class TStackCrawl {
enum {kMaxFrames = 32};
//-----------------------------------
// Initialization/Destruction
//
public:
~TStackCrawl();
TStackCrawl(ulong startFrame = 0, ulong numFrames = kMaxFrames);
// Frame numbers start at 0 which is the caller of the TStackCrawl
// constructor and work upwards to the base of the stack.
//-----------------------------------
// API
//
public:
ulong GetNumFrames() const {return mNumFrames;}
SStackFrame GetFrame(ulong frame) const;
StackFrameID GetID(ulong frame) const;
// Returns an identifier (or cookie) that can be used later to
// generate the stack frame.
static SStackFrame GetFrame(StackFrameID id);
static SStackFrame GetCaller();
// Returns the stack frame of the function that called the
// function that called GetCaller.
//-----------------------------------
// Internal API
//
protected:
static SStackFrame GetFrame(size_t pc, bool native);
//-----------------------------------
// Member Data
//
protected:
ulong mNumFrames;
const void* mFrame[kMaxFrames]; // frames starting at startFrame
};